package it.koutifaris.travianmap.physics;

import it.koutifaris.travianmap.physics.Motion.MotionState;

public class UniformAcceleratedMotion implements Motion, MotionState {

	private final double a;
	private double v;
	private double s;

	public UniformAcceleratedMotion(double a, double v0, double s0) {
		this.a = a;
		this.v = v0;
		this.s = s0;
	}

	@Override
	public void update(double delta) {
		v += a * delta;
		s += 0.5 * a * delta * delta + v * delta;
	}

	@Override
	public double speed() {
		return v;
	}

	@Override
	public double position() {
		return s;
	}

	@Override
	public double acceleration() {
		return a;
	}

	@Override
	public MotionState getState() {
		return this;
	}

}
